//checks if the suplied AFM is valid
//returns true for valid , false for invalid
function isValidAFM() {
	//check if afm is number and contains only characters between 0-9
	var afm = document.getElementById("id_afm").value;

	if ( afm.length == 9 || afm.match(/[0-9]+/)) {
		var sum = 0;
		for (i = afm.length - 2; i >= 0; i--) {//from right to left except last digit
			
			sum = sum+afm.charAt(i)*(Math.pow(2,afm.length-(i+1)));
		}
		//if sum = 0 or the remainder of the division with 11 = last digit then afm is valid
		if(sum != 0 && sum%11 == afm.charAt(afm.length-1) )
			return true;
	}
	//mozilla bu fix
	setTimeout("document.getElementById('id_afm').focus()",0);
	
	document.getElementById("id_afm").setAttribute("style","background-color:red");
	document.getElementById("id_afm").focus();
	return false;
}


function isValidAmount(){
	
	var amount  = document.getElementById("id_amount").value;
	var pattern = /^[0-9]+((\.|,)([0-9]){0,2})?$/
	if (amount.match(pattern))
		return true;
	alert("usage 1 ./, 00 ");
	return false;
}

function isValidDescr(){
	
	var descr  = document.getElementById("id_storeDescription").value;
	
	if (descr.length <= 24)
		return true;
	
	alert("too big");
	return false;
	
}
